[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
fwrite() Write Unformatted Data to Stream
#include <stdio.h>
size_t fwrite(buffer,size,count,stream);
const void *buffer; Pointer to data to be written
size_t size; Item size in bytes
size_t count; Max number of items to be written
FILE *stream; Pointer to file structure
fwrite() writes up to 'count' items of data, each of length 'size'
bytes, from 'buffer' to the output 'stream', at the location of the
current file pointer, if appropriate. If there is a file pointer
associated with 'stream', it is incremented by the number of bytes
actually written.
Returns: The number of data items actually written. The
number may be less than 'count' if an error occurs.
Notes: If 'stream' was open in text mode, each carriage-
return is replaced with a carriage-return-line-feed
pair. This has no effect on the return value.
-------------------------------- Example ---------------------------------
The following statements open a file for appending and write the
contents of a buffer.
#include <stdio.h>
FILE *stream;
char buffr[128];
main()
{
if ((stream = fopen("data.bak","a+"))!= NULL) {
.
.
.
fwrite(buffr,sizeof(char),128,stream);
}
}
See Also:
fread()
write()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson